package com.zzpct.wh.work.kotlin

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST

class MainActivity : AppCompatActivity() {

    interface SearchService{
        @FormUrlEncoded
        @POST("Interface/UserLine/search")
        fun search(@Field("pos") i:Int): Call<SearchData>
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        JavaClassNew.f3()
        SearchData("r","8", listOf())
        var retrofit = Retrofit.Builder()
            .baseUrl("http://hh1.me:5001")
            .addConverterFactory(GsonConverterFactory.create())
            .build()
        val searchService = retrofit.create(SearchService::class.java)
        var allsearch = searchService.search(1)
        allsearch.enqueue(object :Callback<SearchData>{
            override fun onFailure(call: Call<SearchData>, t: Throwable) {

            }

            override fun onResponse(call: Call<SearchData>, response: Response<SearchData>) {
                tv.text=response.body()?.message

            }

        })



    }
    fun f1(){

    }


}
